import os
'''
读取文件夹下所有文件的名字并把他们用列表存起来
'''
repo_list = ["tensorflow", "netbeans", "phoenix", "Katello", "kuma", "moby", "opencv", "react", "scikit-learn", "terraform"]
for repo_name in repo_list:
    file_path = "./" + repo_name + "/"
    proj_name = file_path + "simdata"
    print(proj_name)
    datanames = os.listdir(proj_name)
    list = []
    for i in datanames:
        list.append(i)
    print(list)

    rename = ["model_time", "simulation_open", "create_num", "merge_num",
              "review_num", "pr_total_time", "pr_review_time", "review_time/total_time",
              "merge_num/create_num", "merge_num/review_num", "open_before_review",
              "open_time", "review_num/open_num", "pr_review_time/open_time"]

    import pandas as pd

    # 导入数据
    agl_name = list[0]
    for agl_name in list:
        data = pd.read_excel(proj_name + '/' + agl_name)
        print(data)
        rename_dict = dict()
        for i in range(0, 14):
            rename_dict[data.columns[i + 10]] = rename[i]

        print(rename_dict)
        data.rename(columns=rename_dict, inplace=True)
        print(data)

        x = pd.DataFrame(data)
        print(x)
        x.to_excel(proj_name + '/' + agl_name, index=False)


